Avoiding Data Explosion

In some cases, many data intersections unintentionally explode in the cube with unintended values. This can occur in multi-dimensional data structures.

Example: An application has one entity, four fccounts, 100 products (UD1) and 100 customers (UD2). 

The user has entered three numbers in the system.

Copy
(A#Sales:U1#Prod1:U2#Cust1=22.0,   A#Sales:U1#Prod5:U2#Cust1=33.0, A#Sales:U1#Prod7:U2#Cust100=55.0).  

The following cases explain what happens when writing the following formulas.

No Explosion

Use the following statement to set the value of a data intersection equal to another or a constant value.

Copy
api.Data.Calculate(“A#Cash1 = A#RestrictedCash”)

The Cash1 account equals the value in the Restricted Cash account.  The only populated UD1 and UD2 members are the None members, because Cash is not typical to delineate by product or customer.

Copy
api.Data.Calculate(“A#Profit:U2#Cust1 = A#Sales * 1.05”)

Two of the three Sales values are multiplied by 1.05 and copied to the Profit account. Only the Sales values for Customer 1 are used as the source.

Some Explosion

Copy
api.Data.Calculate(“A#Profit = A#Sales:U2#Cust1”)  

The user specified a customer for source data but did not specify which customer to use when writing to the destination. This means answers are written to every base-level member of the customer dimension, resulting in some data explosion. The Profit account has a number for every customer (UD2) using the same product (UD1) member as the source numbers. Profit account will have 300 numbers, but because there were three different source products, there will be some data explosion.

Not specifying a member for a dimension is equivalent to specifying All for a member.  If All is specified on the left only, data explosion occurs. Some level of data explosion occurs in the following examples:

  • The right side of an equation identifies a specific member or amount.

  • The left side of an equation specifies All for one or more dimensions.

Large-scale Explosion when Setting to a Constant

Copy
api.Data.Calculate(“A#Profit = 2.0”)

Profit will have 1000 numbers stored that are all products by all customers, causing large scale explosion.  However, this example is overly simple. If all dimensions are used, trillions of numbers may be stored. A constant is the same as not specifying All for every dimension on the right side of the equation.

Writing Formulas to Avoid Data Explosion

If a member is specified for a dimension on the right side of the equation, explicitly specify a value for that dimension on the left side. The following examples are the same as the previous examples with some explosion and large-scale explosion when setting to a constant, but this time the formulas are written to avoid data explosion.

Specify a Target on the Left Side of the Equation

api.Data.Calculate(“A#Profit = A#Sales:U2#Cust1”) would be better written as api.Data.Calculate(“A#Profit:U2#Cust1 = A#Sales:U2#Cust1” ) if that is what is intended. If the user intended on copying Cust1’s sales figures to every customer intersection under the Profit account, the formula would need to be written as the following example:

Copy
api.Data.Calculate(“A#Profit:U2#All = A#Sales:U2#Cust1”

api.Data.Calculate(“A#Profit = 2.0”) will fail since the constant of 2.0 implies all members from each dimension.  In order for this formula to run, it needs to be api.Data.Calculate(“A#Profit:F#All:O#All:I#All:U1#All:U2#All:U3#All:U4#All:U5#All:U6#All:U7#All:U8#All = 2.0”). Although, the user may choose to do otherwise.

Avoiding Data Explosion in Stored Formulas

When writing stored calculations, the member script equations in api.Data.Calculate read or calculate one or more data buffers for the purpose of saving a resulting data buffer. As described earlier, thousands of data cells could be processed using a seemingly simple one-line formula.

Data explosion can occur when a formula is inadvertently written to read or calculate a data buffer and then copy all  data cells in that data buffer multiple times to every base-level member of a dimension using the resulting data buffer (often causing hundreds of thousands of new numbers to be saved). We only apply calculation to intersections where data exists. Fortunately, OneStream protects the user from writing formulas that could result in data explosion, but the concepts are important to understand because it is possible to circumvent those protections.

Consider the formula from an earlier example:

Copy
api.Data.Calculate("A#Sales1 = A#Sales2 + A#Sales3”)

Now, the formula is changed, so it only copies the sales data for specific customers with UD2 being the customer dimension.

Copy
api.Data.Calculate("A#Sales1:U2#None = A#Sales2:U2#CustomerX + A#Sales3:U2#CustomerY”)

This formula will not result in data explosion because there is the same level of detail (that is, the same dimensions) specified in the destination as in every source operand. The example now reads the Sales2 data for CustomerX, adds it to the Sales3 data for CustomerY, and saves the results in the Sales1 account and the UD2 None member.

The following formula is written to cause data explosion:

Copy
api.Data.Calculate("A#Sales1 = A#Sales2:U2#CustomerX + A#Sales3:U2#CustomerY”)

The UD2 dimension is specified for the source operands, which is the right side of the equal sign, but UD2 is not specified for the destination, which is the left side of the equal sign.

When processing this formula, OneStream will read the two data buffers and add them together correctly as before. However, it then needs to assign the combined data buffer to the Sales1 account. However, the system cannot use U2#CustomerX or U2#CustomerY because data cells were created by adding those together, and it cannot arbitrarily choose one over the other. The system could also have defaulted to use the U2#None member, but history suggests that this type of rule is more often written in error, and the customer did not intend the results to be stored in the U2#None member. From a maintenance perspective, it is recommended to explicitly specify U2#None if that is the intended destination member.

If something like this were to happen, OneStream will provide an error message notifying the user that data explosion will occur when trying to run the previous formula. Otherwise, the formula will copy the source data buffer to every base-level UD2 member because #All is the default setting for each unspecified member.

To override the error message and force data explosion, explicitly specify U2#All in the destination as shown in the following example. Do not do this. #All should never be used in member scripts for stored formulas. However, the capability is provided for extremely rare circumstances where that functionality relied on using an older product. In this case, the consultant carefully analyzed the quantity of data and metadata settings to ensure the data explosion resulted in a manageable number of data cells.

CAUTION: This causes Data Explosion. Never use #All explicitly in stored Member Formulas.

Copy
api.Data.Calculate("A#Sales1:U2#All = A#Sales2:U2#CustomerX + A#Sales3:U2#CustomerY”)